$(function(){
	/*
	 * 搜索约局
	 */
	$('.gather-search-btn').on('click',function(){
		$('#searchForm').submit();
	});

	/*
	 * 屏蔽局
	 */
	$('.gather-ban-btn').on('click',function(){
		var $this = $(this);
		var $banBtns = $this.parent().find('.gather-ban-btn');
		var gid = $this.parents('tr').attr('data-gathering-id');
		var isDeleteBtn = !$this.hasClass('unban');
		var url = '/gather/gathering/gather/delete';
		var msg = isDeleteBtn ? '确定屏蔽这个局吗？' : '确定取消屏蔽这个局吗？';
		var isDelete = isDeleteBtn ? '1' : '0';
		actionConfirm({
			msg: msg,
			confirm: function(){
				cAjax({
					url: url,
					data: {
						gid: gid,
			   			isDelete: isDelete	
					},
					success: function(obj) {
						$banBtns.toggle();
					}
				});	
			}
		});	
	});

	/*
	 * 局置顶
	 */
	$('.top-btn').on('click',function(){
		var $this = $(this);
		var $topBtns = $this.parent().find('.top-btn');
		var gid = $this.parents('tr').attr('data-gathering-id');
		var isTopBtn = !$this.hasClass('untop');
		var url = '/gather/gathering/gather/isTop';
		var msg = isTopBtn ? '确定要置顶这个局吗？' : '确定要取消置顶这个局吗？';
		var isTop = isTopBtn ? '1' : '0';
		actionConfirm({
			msg: msg,
			confirm: function(){
				cAjax({
					url: url,
					data: {
						gid:gid,
						isTop: isTop
					},
					success:function(obj){
						$topBtns.toggle();
					}
				});
			}	
		});
	});	

});
